package rowan.application.quickaccess.tabs;

import rowan.application.quickaccess.R;
import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;

/* This class displays information About Rowan University
 *  This includes: Links to request Information, Rowan Facebook,
 *  				tour dates, why rowan(.com), and Rowan admissions page
 *  
 *  There are two ways the links are shown/done (They all open androids web browser)
 *  
 *   Method 1: Using a button, and setting the background to selected image.
 *   		   Then creating an anonomys Click Listener for the button and giving
 *   		 	each listener the Intent with a URL address to be opened by the web browser.
 *   
 *   Method 2: Using a TextView to have links to certain web pages.
 *   		   Each TextView uses this class as a Click Listener, (This is why the TextViews need to be fields)
 *   		   When Clicked, the method onClick checks the references and starts a specific web URL intent
 */
public class AboutRowan extends Activity implements OnClickListener{
	
	TextView tours, why, admissions;

	/** Called when the activity is first created.
	 * 
	 *  Calls on buttons and textViews from aboutpage.xml
	 *  Using method 1 and method 2, onClickListeners are given
	 *  In this implementation there is no prefence to method 1 or 2
	 */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.aboutpage); 
        
        // REQUEST INFORMATION [BUTTON]
        Button information = (Button)findViewById(R.id.info);
        information.setOnClickListener(new OnClickListener() {
        	public void onClick(View v) {
        		Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://ru.rowan.edu/"));
                startActivity(intent);

        	}
        }); 
        
        //FACEBOOK [BUTTON]
        Button facebook = (Button)findViewById(R.id.facebook);
        facebook.setOnClickListener(new OnClickListener() { 
        	public void onClick(View v) {
        		Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.facebook.com/pages/Glassboro-NJ/Rowan-University/37215990667"));
                startActivity(intent);
        	}
        }); 
        
        // Quick Access 
        ImageView quickaccess = (ImageView)findViewById(R.id.facebookfan);
        quickaccess.setOnClickListener(new OnClickListener() {
        	public void onClick(View v) {
        		Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.facebook.com/pages/Rowan-Quick-Access/127595857272496"));
        		startActivity(intent);
        	}
        });

        tours = (TextView)findViewById(R.id.tours);
        tours.setOnClickListener(this);
        
        why = (TextView)findViewById(R.id.why);
        why.setOnClickListener(this);
        
        admissions = (TextView)findViewById(R.id.admissions);
        admissions.setOnClickListener(this);
    } 	
        
    
    /**
     * The required method for implementing OnClickListener to this activity
     * Any object that is listening to this activity will execute this method when clicked
     * 
     * The View v is compared to the TextViews that are on the about page, and execute the given intent
     * 
     * @param v The View clicked on
     */
	@Override
	public void onClick(View v) {
		
		if (v == tours)
		{
			Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.rowan.edu/provost/academic_affairs/admissions/campustours/"));
            startActivity(intent);
		}
		
		if (v == why)
		{
			Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.whyrowan.com/"));
            startActivity(intent);
		}
		
		if (v== admissions)
		{
			Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.rowan.edu/provost/academic_affairs/admissions/index.cfm"));
            startActivity(intent);
		}
	}
	
}
        
        